﻿@*@model IEnumerable<FinancePortal.Domain.Model.Area>*@
@{
    ViewBag.Title = "Index";
}

<div id="AreaTable" style="width: 780px; margin: auto;"></div>

<script type="text/javascript">
    $(document).ready(function () {
        $('#AreaTable').jtable({
            title: 'Area List',
            paging: true,
            pageSize: 10,
            defaultSorting: 'Name ASC',
            sorting: true,
            columnResizable: true,
            columnSelectable: true,
            saveUserPreferences: true,
            actions: {
                listAction: '@Url.Action("/AreaList")'
                @if (Convert.ToBoolean(Session["IsAdmin"])  ){
                    @:, deleteAction: '@Url.Action("/DeleteArea")',updateAction: '@Url.Action("/UpdateArea")',createAction: '@Url.Action("/CreateArea")'
                }
            },
            fields: {
                Id: {
                    key: true,
                    create: false,
                    edit: false,
                    list: false
                },
                Name: {
                    title: 'Name',
                    width: '40%',
                    inputClass: 'validate[required,max[50]]'
                },
                ParentAreaId: {
                    title: 'Parent Area',
                    width: '25%',
                    options: '@Url.Action("/GetParent")'
                },
                AreaClient: {
                    title: 'Area Client',
                    width: '15%',
                    type: 'checkbox',
                    values: { 'false': 'No', 'true': 'Yes' },                     
                    defaultValue: 'false'
                }
            },
            formCreated: function (event, data) {
                data.form.validationEngine();
            },
            formSubmitting: function (event, data) {
                return data.form.validationEngine('validate');
            },
            formClosed: function (event, data) {
                data.form.validationEngine('hide');
                data.form.validationEngine('detach');
            }
        });

        //Load person list from server
        $('#AreaTable').jtable('load');
    });

</script>

@*<style type="text/css">
    table 
    {
      border: solid 1px #e8eef4;
      border-collapse: collapse;
    }

    table td 
    {
      padding: 5px;   
      border: solid 1px #e8eef4;
    }

    table th
    {
      padding: 6px 5px;
      text-align: left;
      background-color: #e8eef4; 
      border: solid 1px #e8eef4;   
    }
</style>
<p>
    @Html.ActionLink("Create New", "Create")
</p>
<table>
    <tr>
        <th>
        </th>
        <th>
            Name
        </th>
        <th>
            Parent Area
        </th>
    </tr>
    @foreach (var item in Model)
    {
        <tr>
            <td>
                @Html.ActionLink("Edit", "Edit", new { id = item.Id }) |
                @Html.ActionLink("Delete", "Delete", new { id = item.Id },
                    new { onclick = "return confirm('Are you sure you wish to delete this activity?');" })
            </td>
            <td>
                @item.Name
            </td>
            <td>
                @if (item.ParentArea != null)
                {
                    @item.ParentArea.Name
                }
            </td>
        </tr>
    }
</table>*@

<script>
    $(document).ready(function () {
        $('#pageTitle').text('Areas');
    });
//    var path = 'Url.Content("~/xml/menu-config.xml")';
//    var brand = new brand('Area', '', 'top', path);
//    createSectionTitleName();
//    createFontWidget('all', 'yes');
</script>